package com.test.daily.leetcode.y2022.m07.day0710.office.v01;

/**
 * @descriptions:
 * @author: Tom
 * @date: 2022/7/10 上午 09:02
 * @version: 1.0
 */
public class Solution {
    public static class Clock {
        protected String mTimezone; // 实例属性
        public Clock(String timezone) { // 构造函数
            mTimezone = timezone;
        }
        public void greeting() { // 实例方法
            System.out.println("A clock - " + mTimezone);
        }
    }
    public static class PrettyClock extends Clock { // 类的派生
        protected String mColor;
        public PrettyClock(String timezone, String color) {
            super(timezone); // 调用父类的构造函数
            mColor = color;
        }
        @Override
        public void greeting() { // 重写(override)父类的一个方法
            System.out.println("A clock - " + mTimezone + " + "+ mColor);
        }
    }
    public static void demo() {
        Clock clock1 = new Clock("London");
        Clock clock2 = new Clock("Shanghai");
        Clock clock3 = new PrettyClock("Chongqing", "RED");
        clock1.greeting(); // -> "A clock - London"
        clock2.greeting(); // -> "A clock - Shanghai"
        clock3.greeting(); // -> "A clock - Chongqing + RED"
    }
    public static void main(String[] args) {
        (new Solution()).demo();
    }
}
